package jobs.poc;

import java.io.IOException;

import jobs.poc.writables.WordPairDecade;
import jobs.poc.writables.WordPairDecadeTimes;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;


public class sumMapper  extends Mapper<LongWritable ,Text , WordPairDecade, WordPairDecadeTimes> {
//public class sumMapper  extends Mapper<LongWritable, Text , Text,Text> {

	@Override
	protected void map(LongWritable key, Text value,
			Context context)
			throws IOException, InterruptedException {
		WordPairDecadeTimes wpdt = WordPairDecadeTimes.fromString(value);
		String firstWord = wpdt.getFirstWord();
		String secondWord = wpdt.getSecondWord();
		int decade = wpdt.getDecade();
		WordPairDecade wpd1 = WordPairDecade.createWordPairDecade(firstWord, secondWord, decade);
		WordPairDecade wpd2 = WordPairDecade.createWordPairDecade(firstWord, "*", decade);
		WordPairDecade wpd3 = WordPairDecade.createWordPairDecade("*", secondWord, decade);
		WordPairDecade wpd4 = WordPairDecade.createWordPairDecade("*", "*", decade);

//		context.write(new Text(wpd1.toString()), new Text(wpdt.toString()));
//		context.write(new Text(wpd2.toString()), new Text(wpdt.toString()));
//		context.write(new Text(wpd3.toString()), new Text(wpdt.toString()));
//		context.write(new Text(wpd4.toString()), new Text(wpdt.toString()));
		
		context.write(wpd1, wpdt);
		context.write(wpd2, wpdt);
		context.write(wpd3, wpdt);
		context.write(wpd4, wpdt);

		
		
	}
	
	

	

	

	


}
